//window.onload = function (){
$(document).ready(function(){
/*$('#doc').MPreview({ 
    url: 'http://newt.ksbao.com/media/data.doc',   //url中包含callback则表示跨越请求，具体可参考$.getJSON();
    data: null,                             //包含所有图片地址的数组，如填写则不发送Ajax。用于直接传入数据，方便调用。
    offset: 100,                            //每次滚动偏移多少像素，默认 100px
    loadSize: 5,                            //每次加载几张图片
    pageFix: 50,                            //当前页数判定的衡量标准
    scrollFix: 5,                           //当前默认滚动条距离外容器的边距
    minScrollHeight: 20                     //当前滚动条按钮最小高度
});*/
/*$('#ppt').MPreviewPPT({ 
    url: 'api.php?action=doc&callback=?',   //url中包含callback则表示跨越请求，具体可参考$.getJSON();
    data: null,                             //包含所有图片地址的数组，如填写则不发送Ajax。用于直接传入数据，方便调用。
    loadSize: 5,                            //每次加载几张图片
    scrollFix: 5,                           //当前默认滚动条距离外容器的边距
    minScrollHeight: 20                     //当前滚动条按钮最小高度
});*/
	
var video = document.getElementById('videoPlayer');	
//video.controls = false;
document.getElementById('playPause').onclick = function(){
	togglePlayPuse();	
};//播放/暂停按钮单击事件
document.getElementById('volume').onchange = function(){
	setVolume();
};	//当滚动条滑动时，调整音量大小
video.addEventListener('timeupdate',updateProgress,false);	//事件监听，当timeupdate事件被激活时，调用updateProgress函数改变进度条
video.addEventListener('play',function(){
	var playPause = document.getElementById('playPause');	
	playPause.title = '暂停';	
	playPause.src = '../img/pause.png';
},false);	//监听播放事件
video.addEventListener('pause',function(){
	var playPause = document.getElementById('playPause');	
	playPause.title = '播放';	
	playPause.src = '../img/play.png';
},false);	//监听暂停事件
video.addEventListener('end',function(){
	this.pause();
},false);	//监听视频结束事件


function togglePlayPuse(){
	var playPause = document.getElementById('playPause');	
	if(video.paused || video.ended){
		playPause.title = '暂停';	
		playPause.src = '../img/pause.png';
		video.play();
	}else{
		playPause.title = '播放';	
		playPause.src = '../img/play.png';
		video.pause();	
	}
}
function setVolume(){
	var volume = document.getElementById('volume');
	video.volume = volume.value;
}
function updateProgress(){
	var progress = document.getElementById('progress');
	var value = 0;
	if(video.currentTime > 0){
		value = Math.floor((100 / video.duration) * video.currentTime);	
	}
	progress.style.width = value + '%';
}
function resetPlayer(){
	var playPause = document.getElementById('playPause');	
	playPause.title = '播放';	
	playPause.src = '../img/play.png';
	if(video.currentTime > 0){
		video.currentTime = 0;	
	}
	updateProgress();
}
resetPlayer();
//video.load();

document.getElementById('fullScreen').onclick = function(){
		
};
/*document.getElementById('discussBtn').onclick = function(){
	if(document.getElementById('discussBtn').className.split(' ')[1] === 'rightLi'){
		document.getElementById('discussBtn').className = 'col-lg-6 rightLiActive';
		document.getElementById('notesBtn').className = 'col-lg-6 rightLi';	
		document.getElementById('discussDiv').style.display = 'block';
		document.getElementById('notesDiv').style.display = 'none';
	}else{
		document.getElementById('discussBtn').className = 'col-lg-6 rightLi';	
		document.getElementById('notesBtn').className = 'col-lg-6 rightLiActive';	
		document.getElementById('discussDiv').style.display = 'none';
		document.getElementById('notesDiv').style.display = 'block';
	}
};*/
/*document.getElementById('notesBtn').onclick = function(){
	if(document.getElementById('notesBtn').className.split(' ')[1] === 'rightLi'){
		document.getElementById('notesBtn').className = 'col-lg-6 rightLiActive';
		document.getElementById('discussBtn').className = 'col-lg-6 rightLi';
		document.getElementById('notesDiv').style.display = 'block';	
		document.getElementById('discussDiv').style.display = 'none';
	}else{
		document.getElementById('notesBtn').className = 'col-lg-6 rightLi';	
		document.getElementById('discussBtn').className = 'col-lg-6 rightLiActive';
		document.getElementById('notesDiv').style.display = 'none';	
		document.getElementById('discussDiv').style.display = 'block';
	}
};*/
//};
});